package cn.cdeden.aiqa.dubbo;

import cn.cdeden.aiqa.domain.bo.DifyCreateByFileBo;
import cn.cdeden.aiqa.domain.bo.DifyCreateByTextBo;
import cn.cdeden.aiqa.domain.bo.DifyKnowledgeBaseBo;
import cn.cdeden.aiqa.domain.vo.DifyCreateByFileVo;
import cn.cdeden.aiqa.domain.vo.DifyCreateByTextVo;
import cn.cdeden.aiqa.domain.vo.DifyKnowledgeBaseCreateVo;
import cn.cdeden.aiqa.service.DifyService;
import cn.cdeden.system.api.RemoteDifyService;
import cn.cdeden.system.api.domain.bo.RemoteDifyCreateByFileBo;
import cn.cdeden.system.api.domain.bo.RemoteDifyCreateByTextBo;
import cn.cdeden.system.api.domain.bo.RemoteDifyKnowledgeBaseBo;
import cn.cdeden.system.api.domain.vo.RemoteDifyCreateByFileVo;
import cn.cdeden.system.api.domain.vo.RemoteDifyCreateByTextVo;
import cn.cdeden.system.api.domain.vo.RemoteDifyKnowledgeBaseCreateVo;
import cn.hutool.core.convert.Convert;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

/**
 * Dify服务
 *
 * @author Michelle.Chung
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteDifyServiceImpl implements RemoteDifyService {

    private final DifyService difyService;

    @Override
    public RemoteDifyKnowledgeBaseCreateVo create(RemoteDifyKnowledgeBaseBo bo) {

        DifyKnowledgeBaseCreateVo difyKnowledgeBaseCreateVo = difyService.create(Convert.convert(DifyKnowledgeBaseBo.class,bo));
        return Convert.convert( RemoteDifyKnowledgeBaseCreateVo.class,difyKnowledgeBaseCreateVo);
    }

    @Override
    public RemoteDifyCreateByTextVo createByText(String datasetId, RemoteDifyCreateByTextBo bo) {
        DifyCreateByTextVo difyCreateByTextVo = difyService.createByText(datasetId, Convert.convert(DifyCreateByTextBo.class, bo));
        return Convert.convert(RemoteDifyCreateByTextVo.class,difyCreateByTextVo);
    }

    @Override
    public RemoteDifyCreateByFileVo createByFile(String storageId, String filName, String datasetId, RemoteDifyCreateByFileBo bo) {
        DifyCreateByFileVo difyCreateByFileVo = difyService.createByFile(storageId,filName,datasetId, Convert.convert( DifyCreateByFileBo.class,bo));
        return Convert.convert( RemoteDifyCreateByFileVo.class,difyCreateByFileVo);
    }

    @Override
    public Boolean delete(String datasetId, String documentId) {
        return difyService.delFile(datasetId,documentId);
    }


}
